<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :span="6">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.orderId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="6">
            <a-form-item label="退货单号">
              <a-input placeholder="请输入退货单号" v-model="queryParam.id"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :span="6">
              <a-form-item label="申请状态">
                <j-multi-select-tag v-model="queryParam.status_MultiString" placeholder="请选择申请状态"
                                    dictCode="return_apply_status"/>
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item label="货品状态">
                <j-multi-select-tag v-model="queryParam.productStatus_MultiString" placeholder="请选择货品状态"
                                    dictCode="return_product_status"/>
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item label="钱款状态">
                <j-multi-select-tag v-model="queryParam.moneyStatus_MultiString" placeholder="请选择钱款状态"
                                    dictCode="return_money_status"/>
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item label="申请时间">
                <a-range-picker format="YYYY-MM-DD"
                                :placeholder="['开始时间', '结束时间']"
                                @change="onCreateTimeChange"/>
              </a-form-item>
            </a-col>
          </template>
          <a-col :span="6" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{ x: 1400 }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">处理</a>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <omsOrderReturnApply-modal ref="modalForm" @ok="modalFormOk"/>

  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import OmsOrderReturnApplyModal from './modules/OmsOrderReturnApplyModal'
  import JMultiSelectTag from '../../components/dict/JMultiSelectTag'

  export default {
    name: "OmsOrderReturnApplyList",
    mixins: [JeecgListMixin],
    components: {
      OmsOrderReturnApplyModal,
      JMultiSelectTag
    },
    data () {
      return {
        description: '退货管理管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender:function (t, r, index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            width: 80,
            align:"center",
            scopedSlots: { customRender: 'action' },
          },
          {
            title: '门店',
            width: 120,
            align: 'center',
            dataIndex: 'storeId_dictText'
          },
          {
            title: '订单号',
            align:"center",
            dataIndex: 'orderId'
          },
          {
            title: '退货类型',
            align:"center",
            dataIndex: 'returnType_dictText'
          },
          {
            title: '申请状态',
            align:"center",
            dataIndex: 'status_dictText'
          },
          {
            title: '货品状态',
            align:"center",
            dataIndex: 'productStatus_dictText'
          },
          {
            title: '钱款状态',
            align:"center",
            dataIndex: 'moneyStatus_dictText'
          },
          {
            title: '会员',
            align:"center",
            dataIndex: 'memberId'
          },
          {
            title: '退款金额',
            align:"center",
            dataIndex: 'returnAmount'
          },
          {
            title: '扣除费用',
            align:"center",
            dataIndex: 'deductAmount'
          },
          {
            title: '申请人',
            align:"center",
            dataIndex: 'returnName'
          },
          {
            title: '申请时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '处理人',
            align:"center",
            dataIndex: 'handleMan'
          },
          {
            title: '处理时间',
            align:"center",
            dataIndex: 'handleTime'
          },
          {
            title: '退货系统',
            align:"center",
            dataIndex: 'sourceSystem_dictText'
          }
        ],
        // 请求参数
    	url: {
              list: "/oms/omsOrderReturnApply/list",
              delete: "/oms/omsOrderReturnApply/delete",
              deleteBatch: "/oms/omsOrderReturnApply/deleteBatch",
              exportXlsUrl: "oms/omsOrderReturnApply/exportXls",
              importExcelUrl: "oms/omsOrderReturnApply/importExcel",
           },
        }
      },
      computed: {
        importExcelUrl: function(){
          return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
        }
      },


    methods: {
      onCreateTimeChange: function(value, dateString) {
        console.log(dateString[0], dateString[1])
        this.queryParam.createTime_begin = dateString[0]
        this.queryParam.createTime_end = dateString[1]
      },
      initDictConfig() {
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>